<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
 Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="CompartmentFigure.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>CompartmentFigure.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'CompartmentFigure.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="draw2d/CompartmentFigure.html">draw2d.CompartmentFigure</a></b></td>
    <td>A CompartmentFigure is the base class for figures which can have children.<br>
 You can drag and drop any figure to a CompartmentFigure.</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/* This notice must be untouched at all times.

FreeGroup Draw2D 0.9.26
The latest version is available at
http://www.freegroup.de

Copyright (c) 2006 Andreas Herz. All rights reserved.
Created 5. 11. 2006 by Andreas Herz (Web: http://www.freegroup.de )

LICENSE: LGPL

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA,
or see http://www.gnu.org/copyleft/lesser.html
*/</span>

<span class="comment">/**
 * <span class="attrib">@class</span> A CompartmentFigure is the base class for figures which can have children.&lt;br&gt;
 * You can drag and drop any figure to a CompartmentFigure. At this moment the drag &amp;amp; drop figure
 * is a child of the CompartmentFigure.&lt;br&gt;
 * The CompartmentFigure is a container for other figures. It's a kind of grouping elements.
 *
 * <span class="attrib">@version</span> 0.9.26
 * <span class="attrib">@author</span> Andreas Herz
 * <span class="attrib">@constructor</span>
 */</span>
draw2d.CompartmentFigure=<span class="reserved">function</span>()
{
  draw2d.Node.call(<span class="reserved">this</span>);

  <span class="comment">/** <span class="attrib">@private</span> **/</span>
  <span class="reserved">this</span>.children = new draw2d.ArrayList();

  <span class="reserved">this</span>.setBorder(new draw2d.LineBorder(1));


  <span class="comment">/** <span class="attrib">@private</span> **/</span>
  <span class="reserved">this</span>.dropable = new draw2d.DropTarget(<span class="reserved">this</span>.html);
  <span class="reserved">this</span>.dropable.node = <span class="reserved">this</span>;

  <span class="reserved">this</span>.dropable.addEventListener(<span class="literal">"figureenter"</span>, <span class="reserved">function</span> (oEvent)
  {
    oEvent.target.node.onFigureEnter(oEvent.relatedTarget.node);
  });
  <span class="reserved">this</span>.dropable.addEventListener(<span class="literal">"figureleave"</span>, <span class="reserved">function</span> (oEvent)
  {
    oEvent.target.node.onFigureLeave(oEvent.relatedTarget.node);
  });
  <span class="reserved">this</span>.dropable.addEventListener(<span class="literal">"figuredrop"</span>, <span class="reserved">function</span> (oEvent)
  {
    oEvent.target.node.onFigureDrop(oEvent.relatedTarget.node);
  });
};

draw2d.CompartmentFigure.<span class="reserved">prototype</span> = new draw2d.Node();
  <span class="comment">/** <span class="attrib">@private</span> **/</span>
draw2d.CompartmentFigure.<span class="reserved">prototype</span>.type=<span class="literal">"draw2d.CompartmentFigure"</span>;


<span class="comment">/**
 * Sub class can override this method to reset the highlight or do other stuff.&lt;br&gt;
 * &lt;br&gt;
 * Don't forget to call the super method via &lt;code&gt;Figure.prototype.onFigureEnter.call(this,figure)&lt;/code&gt; if you inherit
 *
 * <span class="attrib">@param</span> {draw2d.Figure} figure The current drag drop figure.
 **/</span>
draw2d.CompartmentFigure.<span class="reserved">prototype</span>.onFigureEnter = <span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> figure)
{
};

<span class="comment">/**
 * Sub class can override this method to reset the highlight or do other stuff.&lt;br&gt;
 * &lt;br&gt;
 * Don't forget to call the super method via &lt;code&gt;Figure.prototype.onFigureLeave.call(this,figure)&lt;/code&gt; if you inherit
 * 
 * <span class="attrib">@param</span> {draw2d.Figure} figure The current drag drop figure.
 * <span class="attrib">@private</span>
 **/</span>
draw2d.CompartmentFigure.<span class="reserved">prototype</span>.onFigureLeave = <span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> figure)
{
};


<span class="comment">/**
 * Sub class can override this method to reset the highlight or do other stuff.&lt;br&gt;
 * &lt;br&gt;
 *
 * <span class="attrib">@param</span> {draw2d.Figure} figure The current drag drop figure.
 **/</span>
draw2d.CompartmentFigure.<span class="reserved">prototype</span>.onFigureDrop = <span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> figure)
{
};


<span class="comment">/**
 * Returns the children of this container figure.
 *
 * <span class="attrib">@return</span> draw2d.ArrayList
 **/</span>
draw2d.CompartmentFigure.<span class="reserved">prototype</span>.getChildren=<span class="reserved">function</span>()
{
   <span class="reserved">return</span> <span class="reserved">this</span>.children;
};

<span class="comment">/**
 * Add the hands over element to this compartment figure. This is a kind of grouping elements
 * 
 * <span class="attrib">@param</span> {draw2d.Figure} figure The new figure to add.
 **/</span>
draw2d.CompartmentFigure.<span class="reserved">prototype</span>.addChild = <span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> figure)
{
  <span class="comment">// The child of a compartment is always above the compartment</span>
  <span class="comment">//</span>
  figure.setZOrder(<span class="reserved">this</span>.getZOrder()+1);
  figure.setParent(<span class="reserved">this</span>);

  <span class="comment">// Add the element to the child array</span>
  <span class="comment">//</span>
  <span class="reserved">this</span>.children.add(figure);
};

<span class="comment">/**
 * Remove the hands over figure from this compartment figure.
 * This method does NOT remove the figure from the cnavas. It only remove the figure in
 * child hirachie of this compartment.
 *
 * <span class="attrib">@param</span> {draw2d.Figure} figure The figure to remove.
 **/</span>
draw2d.CompartmentFigure.<span class="reserved">prototype</span>.removeChild = <span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> figure)
{
  figure.setParent(null);
  <span class="reserved">this</span>.children.remove(figure);
};


<span class="comment">/**
 * <span class="attrib">@param</span> {int} index Set the new z-index of the element
 **/</span>
draw2d.CompartmentFigure.<span class="reserved">prototype</span>.setZOrder=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> index)
{
  draw2d.Node.<span class="reserved">prototype</span>.setZOrder.call(<span class="reserved">this</span>,index);

  <span class="comment">// The child of a compartment must be always above the compartment.</span>
  <span class="comment">//</span>
  <span class="reserved">for</span>(var i=0; i&lt;<span class="reserved">this</span>.children.getSize();i++)
  {
    <span class="reserved">this</span>.children.get(i).setZOrder(index+1);
  }
};

<span class="comment">/**
 * Set the new position of the object
 *
 * <span class="attrib">@param</span> {int} xPos The new x coordinate of the figure
 * <span class="attrib">@param</span> {int} yPos The new y coordinate of the figure 
 **/</span>
draw2d.CompartmentFigure.<span class="reserved">prototype</span>.setPosition=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> xPos , <span class="comment">/*:int*/</span>yPos )
{
  var oldX = <span class="reserved">this</span>.getX();
  var oldY = <span class="reserved">this</span>.getY();
  draw2d.Node.<span class="reserved">prototype</span>.setPosition.call(<span class="reserved">this</span>, xPos, yPos);

  <span class="comment">// Adjust all children figures. The children has an absolute position to the upper left corner</span>
  <span class="comment">// of the paint area and not to the compartment. :-(</span>
  <span class="comment">// TODO:check another solution e.g. relative position of children</span>
  <span class="comment">//</span>
  <span class="reserved">for</span>(var i=0; i&lt;<span class="reserved">this</span>.children.getSize();i++)
  {
    var child = <span class="reserved">this</span>.children.get(i);
    child.setPosition(child.getX()+<span class="reserved">this</span>.getX()-oldX, child.getY()+<span class="reserved">this</span>.getY()-oldY);
  }
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.CompartmentFigure.<span class="reserved">prototype</span>.onDrag = <span class="reserved">function</span>()
{
  var oldX = <span class="reserved">this</span>.getX();
  var oldY = <span class="reserved">this</span>.getY();
  draw2d.Node.<span class="reserved">prototype</span>.onDrag.call(<span class="reserved">this</span>);

  <span class="comment">// Adjust all children figures. The children has an absolute position to the upper left corner</span>
  <span class="comment">// of the paint area and not to the compartment. :-(</span>
  <span class="comment">// TODO:check another solution e.g. relative position of children</span>
  <span class="comment">//</span>
  <span class="reserved">for</span>(var i=0; i&lt;<span class="reserved">this</span>.children.getSize();i++)
  {
     var child = <span class="reserved">this</span>.children.get(i);
     child.setPosition(child.getX()+<span class="reserved">this</span>.getX()-oldX, child.getY()+<span class="reserved">this</span>.getY()-oldY);
  }
};



</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Mon Nov 14 13:45:39 2011</div>
</body>
</html>
